package cn.study.threaded;

/**
 * Created by liang on 2016/8/17.
 */
public class ThreadedTest {
    public static void main(String[] args) {

        ThreadedDemo demo = new ThreadedDemo();
        demo.setNum(3);
        Thread t = new Thread(demo);
        t.start();
        ThreadedDemo demo2 = new ThreadedDemo();
        demo2.setNum(4);
        Thread m = new Thread(demo2);
        m.start();
    }
}

class ThreadedDemo implements Runnable {
    private int num;

    public void run() {
        while (true)
            System.out.println(num);
    }

    public void setNum(int n) {
        num = n;
    }
}
